<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>社医堂</title>
<link rel="stylesheet" type="text/css" href="../../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../../css/hui.css" />
    <link rel="stylesheet" type="text/css" href="../../../css/iconfont.css" />
</head>
<body>
<style>
.input{width:100px; border-bottom:solid 1px #ccc;text-align: center;font-size:25px;}
body{background-color: #fff;}

#health{width:100%}
#health li{float:left;text-align:center;height:36px;line-height:36px;background-color:#7BCAFF;}
</style>

<div class="hui-wrap">

	<div style="padding:20px 25px;border-bottom:solid #ccc 1px;margin-left:3.5%;width:83%;margin-top:10px;">		
		<input type="text" id="userid" placeholder="请输入用户账号" style="width:100%;font-size:25px;" value="" style="border:solid #ccc 5px;height:50px;" />
	</div>

		<div style="padding:20px 25px;">
			<div style="line-height:30px; padding-bottom:8px;">血脂 : <input type="number" id="showValue" value="0" class="input" /></div>
			<div class="hui-range">
				<input type="range" name="" id="range1" min="0" max="100" value="0" />
			</div>
		</div>
		
		<div style="padding:20px 25px;">
			<div style="line-height:30px; padding-bottom:8px;">血糖值 : <input type="number" id="showValue2" value="0" class="input" /> mmol/L</div>
			<div class="hui-range">
				<input type="range" name="" id="range2" min="10" max="350" value="0" />
			</div>
			<div class="hui-range-ruling"></div>
			<div class="hui-range-ruling-txt">
				<div>1.0</div>
				<div>35</div>
			</div>
		</div>

		<div style="padding:10px 25px;">
			<div style="line-height:30px; padding-bottom:8px;" id="showValue3">血压 : <input style="width:60px;" type="number" id="showValue3" value="0" class="input" /> - <input style="width:60px;" type="number" id="showValue4" value="0" class="input" /></div>
			<!-- 组合滑块区 -->
			<div style="background:#E1E1E1; height:20px; border-radius:2px;">
				<div style="width:50%; float:left;">
					<div class="hui-range">
						<input type="range" name="" id="range3_1" min="50" max="110" value="60" />
					</div>
				</div>
				<div style="width:50%; float:right;">
					<div class="hui-range">
						<input type="range" name="" id="range3_2" min="90" max="200" value="90" />
					</div>
				</div>
			</div>
			<div class="hui-range-ruling"></div>
			<div class="hui-range-ruling-txt">
				<div>50</div>
				<div>200</div>
			</div>
		</div>
		
		<div style="padding:10px 25px;;">
			
			<div class="hui-form-select">
				测量时间
				<select id="shiduan" style="float:right;width:200px;">
					<option value="凌晨">凌晨</option>
					<option value="空腹">空腹</option>
					<option value="早餐后2小时">早餐后2小时</option>
					<option value="午餐前">午餐前</option>
					<option value="午餐后2小时">午餐后2小时</option>
					<option value="晚餐前">晚餐前</option>
					<option value="晚餐后2小时">晚餐后2小时</option>
					<option value="睡前">睡前</option>
					<option value="随机">随机</option>
				</select>
			</div>
		</div>
		
		<div style="padding:10px 25px;">
			
			<div class="hui-form-select">
				测量时间
				<input id="shijian" style="float:right;width:200px;height:30px;" type="datetime-local" class="hui-button hui-button-large hui-date-picker" value="2018-09-01" placeholder="测量时间" />
			</div>
			
		</div>
		
		<button type="button" onclick="updata()" class="hui-button hui-button-large hui-primary" style="margin-top:15px;margin-left:30px;width:80%;">提交数据</button>

	
</div>


<script src="../../../script/hui.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../script/hui-tab.js" type="text/javascript"></script>
<script src="../../../script/api.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../script/stm.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
apiready = function() {
	
	hui('#range1').ranging(function(value){
		hui('#showValue').val(value/10);
	});
	hui('#range2').ranging(function(value){
		hui('#showValue2').val(value/10);
	});
	hui('#range3_1').ranging(function(value){
		range2get();
	});
	hui('#range3_2').ranging(function(value){
		range2get();
	});
	hui('.hui-range-ruling').rangeRuling();
	function range2get(){
		var val1 = hui('#range3_1').val();
		var val2 = hui('#range3_2').val();
		hui('#showValue3').val(val1);
		hui('#showValue4').val(val2);
	}



	$api.setStorage('healthnum',0)
	if($api.getStorage('health')!='' && $api.getStorage('health')!=null){
		var health = $api.getStorage('health')+'';
	}else{
		var health = '血压,血脂,血糖,慢性肺阻';
	}


	var healthArr = health.split(",")
	var html = '';
	var width = 100/healthArr.length
	$api.setStorage('healthnum',healthArr.length)

	for(i=0;i<healthArr.length;i++){
		var bg = '';
		if(i==0){ bg = '#4DB8FF'; }
		html += "<li id='t_"+i+"' onclick=tab('"+healthArr[i]+"',"+i+") style='width:"+width+"%;background-color:"+bg+"'>"+healthArr[i]+"</li>"
	}
	hui("#health").html(html)


};

function updata(){

	var xuezhi  = hui('#showValue').val()
	var xuetang = hui('#showValue2').val()
	var diya    = hui('#showValue3').val()
	var gaoya   = hui('#showValue4').val()
	var shiduan = hui('#shiduan').val()
	var shijian = hui('#shijian').val()
	var userid = hui('#userid').val()

	if(userid==''){
		api.toast({ msg:'请输入用户账号',location:'top' })
		return false;
	}

	api.ajax({
        url: $api.getStorage('geturl')+'&c=ajaxmember&a=updata&flag='+$api.getStorage('flag'),
        method: 'post',
        data: {
            values: { 
                userid  : userid,
				docid   : $api.getStorage('docid'),
				hospid  : $api.getStorage('hospid'),
				xuezhi  : xuezhi,
				xuetang : xuetang,
				diya    : diya,
				gaoya   : gaoya,
				shiduan : shiduan,
				shijian : shijian
            }
        }
    },function(ret, err){
        if (ret) {
			//console.log(JSON.stringify(ret))            
			api.toast({ msg:ret.tip,location:'middle' })
			setTimeout("tolist()",1000)
        } else {
            alert( JSON.stringify( err ) );
        }
    });
}

function tolist(){
   toDetails('./','up_record',0)
}
</script>

</body>
</html>